Memories are locations for data storage. When a microprocessor utilizes a memory for storage and readout of data, it will define the position of memory with necessary information so as to transfer data to an accurate address.
A nonvolatile storage medium uses a block composed of a plurality of bytes as the unit for storage and readout of data. Each block for data access has a physical address to represent the space order in the nonvolatile storage medium. Simultaneously, each block records a logical address marked by the file system to let each physical address have a corresponding logical address, as shown in FIG. 1. However, in the mechanism of flash memory, because the correspondence relation between physical addresses and logical addresses required for data access of file system is not linear, logical address cannot be directly inferred from physical address.
Conventionally, there are usually two methods for obtaining a corresponding logical address. In the first method, an AMT (a table for recording the mapping relation between logical address and physical address) is first built when the system is booted, and a plurality of static random access memory (SRAM) are designed to record the AMT, as shown in FIG. 2. When building the AMT, the arrangement order of logical addresses is taken as the principal thing, and the corresponding physical addresses are filled into the table. Because the original logical addresses are irregularly arranged, it is necessary to sort from beginning to end once to build the AMT shown in FIG. 2. This AMT is stored in the SRAMs. When the system accesses data, it will first provide a logical address to be looked up and directly read out the AMT in the SRAMs using firmware, hence quickly obtaining the physical address corresponding to the logical address. Although this way of using the AMT to search logical address has the advantages of short address conversion time and quick processing speed, a large quantity of SRAMs are required for storing all address mapping relations, hence occupying a large space. Moreover, because it is necessary to simultaneously integrate different ICs into a single system chip, the number of SRAMs is fixed. The number of SRAMs cannot increase according to necessity, hence resulting in limit in use.
In the other method of inferring physical address from logical address, there is no SRAM, and it is not necessary to build any AMT. It is only necessary to utilize firmware to search from scratch in the nonvolatile storage medium until the required logical address is found when searching the logical address corresponding to a physical address each time. Because this way is designed without any SRAM, it occupies no space. However, because it is necessary to search the logical address from scratch each time, the search time is long, hence slowing down the speed of data access of nonvolatile storage medium.
Accordingly, the present invention aims to propose a method for detecting logical addresses of a nonvolatile storage medium to resolve the above problems in the prior art.